<include file="Public:header" />
<script>
function del(id){
	if(id)
	{
	  if(confirm("Delete?")){ 
	    location="__URL__/act_add/act/del_category/id/"+id;
      }
	}
}
</script>
<script language="javascript">

function delArc(aid){
	var id=getCheckboxItem();
	if(id)
	{
	  if(confirm("Delete Category?")){ 
	    location="__URL__/act_add/act/del_category/id/"+id;
      }
	}else{
	    alert('Plese choose a category to delete.');
	}
}

//获得选中文件的文件名
function getCheckboxItem()
{
	var allSel="";
	if(document.form2.id.value) return document.form2.id.value;
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
			if(allSel=="")
				allSel=document.form2.id[i].value;
			else
				allSel=allSel+","+document.form2.id[i].value;
		}
	}
	return allSel;
}

function selAll()
{
	for(i=0;i<document.form2.id.length;i++)
	{
		if(!document.form2.id[i].checked)
		{
			document.form2.id[i].checked=true;
		}
	}
}
function noSelAll()
{
	for(i=0;i<document.form2.id.length;i++)
	{
		if(document.form2.id[i].checked)
		{
			document.form2.id[i].checked=false;
		}
	}
}

function change_status(cat_id,is_show)
{
  var show_id = 'is_show_' + cat_id;
  var opt = {
    method: 'get',
    onSuccess: function(t) {
                $(show_id).innerHTML=t.responseText
    },
    on404: function(t) {
                $(show_id).innerHTML='Error: Cannot find submit page!';
    },
    onFailure: function(t) {
                $(show_id).innerHTML='Error:' + t.status + ' -- ' + t.statusText;
    },
        asynchronous:true        
   }

   var ajax=new Ajax.Request('__URL__/act_add/act/update_category_ajax/is_ajax/1/cat_id/'+cat_id+'/is_show/'+is_show, opt);
}
function change_sort(cat_id, value)
{
   var sort_id = 'sort_' + cat_id;
   $(sort_id).innerHTML = "<input type=\"text\" name=\"sort_"+cat_id+"\" id=\"sort_"+cat_id+"\" value='"+value+"' onBlur=\"do_change_sort('"+cat_id+"')\">";
}	
function do_change_sort(cat_id)
{
   var sort_id = 'sort_' + cat_id;
   var data = document.forms['form2'].elements[sort_id].value;
   var opt = {
    method: 'get',
    onSuccess: function(t) {
                $(sort_id).innerHTML=t.responseText
    },
    on404: function(t) {
                $(sort_id).innerHTML='Error: Cannot find submit page!';
    },
    onFailure: function(t) {
                $(sort_id).innerHTML='Error' + t.status + ' -- ' + t.statusText;
    },
        asynchronous:true        
   }

   var ajax=new Ajax.Request('__URL__/act_add/act/update_category_ajax/is_ajax/2/cat_id/'+cat_id+'/sort/'+encodeURIComponent(data), opt);
}	
</script>
<div id="content">
<!--  内容列表   -->
<form name="form2" style="margin-bottom:0px;">
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D1DDAA" align="center" style="margin-top:8px; margin-bottom:0px;">
<tr bgcolor="#E7E7E7">
	<td height="30" colspan="10"><span style="float:left; padding-top:3px; padding-left:5px;">Post Category List</span><span style="float:right;"><input type='button' class="coolbg np" onClick="location='__APP__/Postcategory/add';" value='Add New Category' /></span></td>
</tr>
<tr align="center" bgcolor="#FAFAF1" height="22">
	<th width="8%">ID</th>
    <!--
	<th width="5%">选择</th>
    -->
	<th width="32%">Category name</th>
	<th width="14%">Parent ID</th>
	<th width="10%">Order</th>
	<th width="6%">Display</th>
	<th width="7%">Operation</th>
    <th width="">Language List</th>
</tr>

<foreach name="categoty" item="data" >
<if condition="$data.cat_id neq '' ">
<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#FCFDEE';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="22" >
	<td>{$data.cat_id}</td>
    <!--
	<td><input name="id" type="checkbox" id="id" value="{$data.cat_id}" class="np"></td>
    -->
	<td align="left"><a href='__URL__/edit/cat_id/{$data.cat_id}'><u>{$data.cat_name}</u></a></td>
	<td>{$data.parent_id}</td>
	<td><span id="sort_{$data.cat_id}"><a>{$data.sort_order}</a></span></td>
	<td id="is_show_{$data.cat_id}"><if condition="$data.is_show eq 1"><a>Yes</a><else /> <a>No</a></if></td>
	<td><a href="__URL__/edit/cat_id/{$data.cat_id}">Edit</a> | <a href="javascript:del({$data.cat_id})">Delete</a></td>
    <td><a href="__URL__/lang_index/cat_id/{$data.cat_id}">List</a></td>
</tr>
</if>
</foreach>
<tr bgcolor="#FAFAF1">
<td height="28" colspan="10">
	&nbsp;
    <!--
	<a href="javascript:selAll()" class="coolbg">全选</a>
	<a href="javascript:noSelAll()" class="coolbg">取消</a>
	<a href="javascript:delArc(0)" class="coolbg">&nbsp;删除&nbsp;</a>
    -->
</td>
</tr>
</table>
</form>
</div>
<include file="Public:footer" />